package com.waitingresult.net;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;

public class UdpDemo {
    public static void main(String[] args) throws Exception {
        //发送数据
        DatagramSocket ds = new DatagramSocket(10086, InetAddress.getByName("127.0.0.1"));
        byte[] bytes = "你好啊!!!".getBytes(StandardCharsets.UTF_8);
        DatagramPacket  dp = new DatagramPacket(bytes,bytes.length);
        ds.send(dp);
        ds.close();
    }
}
